** Replication Code for:
** Terrorism Activates Ethnocentrism to Explain Greater Willingness to 
** Sacrifice Civil Liberties: Evidence from Germany
** Authors: Christina Novak Hansen and Peter Thisted Dinesen 
** Date: 10/02/2021

*-------------------------------------------------------------------------------

clear all
use GGSS2016_analysis.dta
svyset xs11 [pweight=wghtpew], vce(linearized)


*-------------------------------------------------------------------------------
*Appendix J: Balance test: Stability of ethnocentrism throughout the survey period
*-------------------------------------------------------------------------------


*Ethnocentrism index variable
gen tempmean = st_ethno
svy: mean tempmean
sort edate
by edate: egen st_ethno_mean = mean(tempmean) 
by edate: egen st_ethno_sd = sd(tempmean) 
gen st_ethno_UB = st_ethno_mean + 1.96*st_ethno_sd/sqrt(3182)
gen st_ethno_LB = st_ethno_mean - 1.96*st_ethno_sd/sqrt(3182)


								***Figure J1***
	
twoway (scatter st_ethno_mean edate, mcolor(gs9) msize(medsmall) msymbol(circle)) ///
(lowess st_ethno_mean edate, lcolor(black)), ytitle(Ethnocentrism (Mean)) ///
ytitle(, size(medium)) ylabel(0(0.2)1, labsize(medsmall) angle(horizontal)) ///
ymtick(0(0.1)1, grid) xtitle("") xlabel(#6, labsize(medsmall) angle(stdarrow) grid) ///
legend(order(1 "Mean of ethnocentrism per day" 2 "Lowess smooth") size(medium) ///
margin(small) region(fcolor(none) lcolor(none)))

graph export Figure_J1.pdf, replace

drop tempmean

svy: mean st_ethno if st_terrori!=. & sex!=. & st_age!=. & proedu2!=. & work2!=. & treatment1==0 & german==1
estat sd

svy: mean st_ethno if st_terrori!=. & sex!=. & st_age!=. & proedu2!=. & work2!=. & treatment1==1 & german==1
estat sd

ttest st_ethno if st_terrori!=. & sex!=. & st_age!=. & proedu2!=. & work2!=. & german==1, by(treatment1)	
********************************************************************************



				***Not displayed and described in online appendix***

				
*Alternative ethnocentrism measure
tab st_homocult
sum st_homocult 
gen tempmean = st_homocult
svy: mean tempmean
sort edate
by edate: egen st_homocult_mean = mean(tempmean) 
by edate: egen st_homocult_sd = sd(tempmean) 
gen st_homocult_UB = st_homocult_mean + 1.96*st_homocult_sd/sqrt(3182)
gen st_homocult_LB = st_homocult_mean - 1.96*st_homocult_sd/sqrt(3182)

	
twoway (scatter st_homocult_mean edate, mcolor(gs8) msize(medsmall) msymbol(circle)) ///
(lowess st_homocult_mean edate, lcolor(black)), ytitle(Belong to common culture (Mean)) ///
ytitle(, size(medium)) ylabel(0(0.2)1, labsize(medsmall) angle(horizontal)) ///
ymtick(0(0.1)1, grid) xtitle("") xlabel(#6, labsize(medsmall) angle(stdarrow) grid) ///
legend(order(1 "Mean of 'Belong to common culture'" 2 "Lowess smooth") size(medium) ///
margin(small) region(fcolor(none) lcolor(none)))
drop tempmean


*-------------------------------------------------------------------------------
